//
//  main.swift
//  ProxyPattern
//
//  Created by LY on 2017/11/6.
//  Copyright © 2017年 DesignPatterns. All rights reserved.
//

import Foundation

//func getHeader(header:String){
//    let url:URL = URL(string: "http://www.apress.com")!
//    let request = URLRequest(url: url)
//    URLSession.shared.dataTask(with: request) { (data, responder, error) in
//        if let httpResponse = responder as? HTTPURLResponse{
//           if let headerValue = httpResponse.allHeaderFields[header] as? String{
//                print("\(header):\(headerValue)")
//            }
//        }
//    }.resume()
//}
let headers = ["Content-Lenght","Content-Encoding"]
//for header in headers{
//        getHeader(header: header)
//}

let stringURL = "http://www.apress.com"
let proxy = HttpHeaderRequestProxy()
for header in headers {
    if let val = proxy.getHeader(url: stringURL, header: header) {
        print("\(header) \(val)")
    }
}
_ = FileHandle.standardInput.availableData
